/**
 * 
 */
package com.meedoll.manager.std.server.dao;

import java.net.UnknownHostException;

import com.google.gwt.user.client.rpc.IsSerializable;
import com.meedoll.manager.std.client.logon.LogonBean;
import com.mongodb.DB;
import com.mongodb.Mongo;
import com.mongodb.MongoException;
import com.mongodb.MongoURI;

/**
 * @author andy
 * 
 */
public class LogonDao implements IsSerializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private final static LogonDao logonDao = new LogonDao();

	public static LogonDao getInstance() {
		return logonDao;
	}

	public LogonBean existUser(String userName, String pwd) {

		// System.out.println("------------------------");
		LogonBean lb = new LogonBean();
	

		 boolean flag = false;
		 try {
		 Mongo mongo = new Mongo();
		 DB db = mongo.getDB("meedoll");
		 flag = db.authenticate(userName, pwd.toCharArray());
		 System.out.println("flag=="+flag);
		 } catch (UnknownHostException e) {
		 e.printStackTrace();
		 } catch (MongoException e) {
		
		 e.printStackTrace();
		 }
		 System.out.println("数据库验证："+flag);
		 lb.setResult(flag);
		return lb;
	}
}
